<template>
    <!--  本意不想这么写 赶时间 只有复制粘贴 后面的小伙 加油 -->
        <a-form-model ref="ruleForm2" :model="form3" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }" v-if="!isA">
            <a-row :gutter="24">
                <a-col :span="8">
                    <a-form-model-item label="外部报审是否通过：">
                        <a-radio-group v-model="form3.auditPass" disabled>
                            <a-radio :value="1">是</a-radio>
                            <a-radio :value="0">否</a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="form3.auditPass!==0">
                    <a-form-model-item label="外部报审通过时间：" prop="startTime" class="requiredFormItem">
                        <a-date-picker disabled v-model="form3.auditTime"
                                       style="width: 200px"
                                       placeholder="请选择" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
                    </a-form-model-item>
                </a-col>
                <a-col :span="24" v-if="form3.auditPass!==0">
                    <a-form-model-item label="外部报审表：" prop="startTime">
                        <b-upload uploadType="single" disabled business-code="LCM16"
                                  :file-list.sync="form3.fileInfoList"></b-upload>
                    </a-form-model-item>
                </a-col>
            </a-row>
        </a-form-model>
        <div v-else>
            <titleName ref="box" title="一次报审外部信息" />
            <a-form-model ref="ruleForm" :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
                <a-row :gutter="24">
                    <a-col :span="8">
                        <a-form-model-item label="外部报审是否通过：">
                            <a-radio-group disabled v-model="form.auditPass">
                                <a-radio :value="1">是</a-radio>
                                <a-radio :value="0">否</a-radio>
                            </a-radio-group>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="8" v-if="form.auditPass!==0">
                        <a-form-model-item label="一次外部报审通过时间：" prop="startTime" class="requiredFormItem">
                            <a-date-picker disabled v-model="form.auditTime"
                                           style="width: 200px"
                                           placeholder="请选择" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  />
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="24" v-if="form.auditPass!==0">
                        <a-form-model-item label="外部报审表：" prop="startTime">
                            <b-upload disabled uploadType="single" business-code="LCM16"
                                      :file-list.sync="form.fileInfoList"></b-upload>
                        </a-form-model-item>
                    </a-col>
                </a-row>
            </a-form-model>
            <titleName ref="box" title="二次报审外部信息" />
            <a-form-model ref="ruleForm2" :model="form2" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
                <a-row :gutter="24">
                    <a-col :span="8">
                        <a-form-model-item label="外部报审是否通过：">
                            <a-radio-group disabled v-model="form2.auditPass">
                                <a-radio :value="1">是</a-radio>
                                <a-radio :value="0">否</a-radio>
                            </a-radio-group>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="8" v-if="form2.auditPass!==0">
                        <a-form-model-item label="二次外部报审通过时间：" prop="startTime" class="requiredFormItem">
                            <a-date-picker disabled v-model="form2.auditTime"
                                           style="width: 200px"
                                           placeholder="请选择" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  />
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="24" v-if="form2.auditPass!==0">
                        <a-form-model-item label="外部报审表：" prop="startTime">
                            <b-upload disabled uploadType="single" business-code="LCM16"
                                      :file-list.sync="form2.fileInfoList"></b-upload>
                        </a-form-model-item>
                    </a-col>
                </a-row>
            </a-form-model>
        </div>
</template>
<script>
    import { getSupplementInfo } from "@/api/technology"
  export default {
    props: {
      // 显隐控件
      visible: {
        type: Boolean,
        default() {
          return false
        }
      },
      row: {
        type: Object,
        default() {
          return {  };
        }
      }
    },
    data() {
      return {
        form: {
          type: 1,
          auditPass: null,
          auditTime: null,
          fileInfoList: []
        },
        form2: {
          type: 2,
          auditPass: null,
          auditTime: null,
          fileInfoList: []
        },
        form3: {
          type: 0,
          auditPass: null,
          auditTime: null,
          fileInfoList: []
        }
      }
    },
    computed: {
      isA() {
        console.log(this.row.programTypeName, 'this.row.schemeCategory ')
        return this.row.programTypeName === 'A'
      }
    },
    created() {
      this.getSupplementInfo()
    },
    methods: {
      getSupplementInfo(){
        getSupplementInfo({ id:this.$route.query.conId }).then(res=>{
          if(!res.data || !Array.isArray(res.data)) {
            return
          }
          const versionNumber = this.$route.query.versionNumber
          if(this.isA) {
           const form =  res.data.filter(item=>item.type==1&&versionNumber ==item.versionNum)
            if(form&&form.length) {
              form[form.length-1].fileInfoList = form[form.length-1].fileInfo
              this.form = form[form.length-1]
            }

            const form2 =  res.data.filter(item=>item.type==2&&versionNumber ==item.versionNum)
            if(form2&&form2.length) {
              form2[form2.length-1].fileInfoList = form2[form2.length-1].fileInfo
              this.form2 = form2[form2.length-1]
            }
          } else {
            const form3 =  res.data.filter(item=>item.type==0&&versionNumber ==item.versionNum)
            if(form3&&form3.length) {
              form3[form3.length-1].fileInfoList = form3[form3.length-1].fileInfo
              this.form3 = form3[form3.length-1]
            }
          }
        })
      }
    }
  }
</script>